// pages/main-page/main-page.js
Page({
    data: {
        //背景
        p1:"https://pic.imgdb.cn/item/62d68cf6f54cd3f9372334fc.png",
        //hello matcher
        titleBig:"Hello Matcher!",
        titleSmall:"一起运动吧",
        //个人中心
        p4:"https://pic.imgdb.cn/item/62d68d1ef54cd3f93723f49d.png",
        textPersonalCenter: "个人中心",
        //运动选择
        p5:"https://pic.imgdb.cn/item/62f6018016f2c2beb1d19f3c.png",
        sportsArray:['所有项目','足球','篮球','排球','羽毛球','乒乓球','棒球','网球'],
        sportsPicUrlArray:["https://pic.imgdb.cn/item/62f6051516f2c2beb1dd42b3.png",
        "https://pic.imgdb.cn/item/62f6048616f2c2beb1db8024.png",
        "https://pic.imgdb.cn/item/62f6048616f2c2beb1db802b.png",
        "https://pic.imgdb.cn/item/62f6048616f2c2beb1db8047.png",
        "https://pic.imgdb.cn/item/62f6048616f2c2beb1db800a.png",
        "https://pic.imgdb.cn/item/62f6053716f2c2beb1ddabbd.png",
        "https://pic.imgdb.cn/item/62f6053716f2c2beb1ddabea.png",
        "https://pic.imgdb.cn/item/62f6053716f2c2beb1ddabba.png",],
        sportsNum:0,
        //发起
        p2:"https://pic.imgdb.cn/item/62d68d18f54cd3f93723d2b1.png",
        //组队
        p3:"https://pic.imgdb.cn/item/62d68d1cf54cd3f93723e9e4.png",

    },
    onLoad:function(options){    //获取用户信息
        this.setData({
            'sportsNum':0,
        })
    },
    toPage_indivitual_page:function(e){    //个人中心
        var app = getApp();
        if(app.globalData.isLogin){
            wx.navigateTo({
            url: '/pages/indivitual-page/indivitual-page',
            })
        }
        else{
            wx.showModal({
              showCancel:false,
              title:"请先登录",
              success(res){
                wx.navigateTo({
                    url: '/pages/login-Page/login-Page',
                  })
              }
            });

        }
    },
    onChangeSports:function(e){    //运动选择
        var x = e.detail.value;
        this.setData({
            [`sportsNum`]: x,
        });
    },
    //发起组队
    toPage_new_room_page:function(e){
          var app = getApp();
          if(app.globalData.isLogin){
            wx.navigateTo({
                url: '/pages/new-room-page/new-room-page?sportsNum='+this.data.sportsNum,
            })
          }
          else{
            wx.showModal({
                showCancel:false,
                title:"请先登录",
                success(res){
                    wx.navigateTo({
                        url: '/pages/login-Page/login-Page',
                      })
                }
              });
          }
        
    },
    toPage_show_rooms_page:function(e){

          var app = getApp();
          if(app.globalData.isLogin){
            wx.navigateTo({
                url: '/pages/show-rooms-page/show-rooms-page?sportsNum='+this.data.sportsNum,
              })
          }
          else{
            wx.showModal({
                showCancel:false,
                title:"请先登录",
                success(res){
                    wx.navigateTo({
                        url: '/pages/login-Page/login-Page',
                      })
                }
              });

          }
    },
})